﻿//
//  RandomEvents
//  Trukkr
//
//  Created by Mathew Purchase 2014.
//  Copyright (c) 2014 Pariah Air. All rights reserved.
//

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;

//---------------------------------------------------------------------------------------------
// Description and Goals.
// This will serve as a modular popup control script that should allow me to change any value
// under player storage. It'll also spice the game up a little with zazzy handwritten descriptions
// of random events.

// The special case events should be handled under the boolean isUpgrade. 
// these will be one time offers to the player for significant upgrades to their rig at a cost of 
// one of the existing values. 

// Settlement Service will fire this script OnEnable. BAAHHHHHH nope. This needs to happen when you return to the settlement screen from the game view.



public class RandomEvent : MonoBehaviour 
{

	//---------------------------------------------------------------------------------------------
	// Properties
	public int resultCount;
	public float resultCash;
	public float resultFuel;
	public float resultHull;
	public int resultFood;
	public int resultWater;
	public int resultHooch;
	public int resultParts;
	
	public bool isUpgrade;

	
	
	//---------------------------------------------------------------------------------------------
	// Members 
	
	public PlayerStorage m_Storage;
	
	//---------------------------------------------------------------------------------------------
	// Core Functions
	
	public void EventResults()
	{
		m_Storage.cash += resultCash;
		
		m_Storage.fuel += resultFuel;
		if (m_Storage.fuel > m_Storage.maxfuel )
		{
			m_Storage.fuel = m_Storage.maxfuel;
		}
		if (m_Storage.fuel < 10 )
		{
			m_Storage.fuel = 10;
		}
		
		m_Storage.hull += resultHull;
		if (m_Storage.hull > m_Storage.maxhull )
		{
			m_Storage.hull = m_Storage.maxhull;
		}
		if (m_Storage.hull < 10 )
		{
			m_Storage.hull = 10;
		}
		
		m_Storage.foodQuantity += resultFood;
		if (m_Storage.foodQuantity > m_Storage.maxcarry )
		{
			m_Storage.foodQuantity = Mathf.FloorToInt(m_Storage.maxcarry);
		}
		if (m_Storage.foodQuantity <  0)
		{
			m_Storage.foodQuantity = 0;
		}
		
		m_Storage.waterQuantity += resultWater;
		if (m_Storage.waterQuantity > m_Storage.maxcarry )
		{
			m_Storage.waterQuantity = Mathf.FloorToInt(m_Storage.maxcarry);
		}
		if (m_Storage.waterQuantity <  0)
		{
			m_Storage.waterQuantity = 0;
		}
		
		m_Storage.hoochQuantity += resultHooch;
		if (m_Storage.hoochQuantity > m_Storage.maxcarry )
		{
			m_Storage.hoochQuantity = Mathf.FloorToInt(m_Storage.maxcarry);
		}
		if (m_Storage.waterQuantity <  0)
		{
			m_Storage.waterQuantity = 0;
		}
		
		m_Storage.partsQuantity += resultParts;
		if (m_Storage.partsQuantity > m_Storage.maxcarry )
		{
			m_Storage.partsQuantity = Mathf.FloorToInt(m_Storage.maxcarry);
		}
		if (m_Storage.waterQuantity <  0)
		{
			m_Storage.waterQuantity = 0;
		}
	
		
	}
	
	//---------------------------------------------------------------------------------------------
	
	public void UpgradeEvent(int upgradeNumber)
	{
	
	if (isUpgrade == true);
	{
			switch (upgradeNumber)
			{
				case 0:
				{
					
					break;
				}
				case 1:
				{
					
					break;
				}
				case 2:
				{
					
					break;
				}
				case 3:
				{
					
					break;
				}
				case 4:
				{
					
					break;
				}
				case 5:
				{
					
					break;
				}
				case 6:
				{
					
					break;
				}
				case 7:
				{
					
					break;
				}
			}
	}
	
	
	}
	
	//---------------------------------------------------------------------------------------------
	
	
}
